package com.shopoo.behavior.infrastructure.database.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shopoo.behavior.infrastructure.database.dataobject.TBehaviorLike;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Description: 点赞持久化
 * @Package com.szmengran.behavior.mapper
 * @date Mar 4, 2019 11:36:49 AM
 * @author <a href="mailto:android_li@sina.cn">Joe</a>
 */
@Mapper
public interface LikeMapper extends BaseMapper<TBehaviorLike> {

    /**
     * 获取分享人的点赞数量
     * @param promotionid
     * @param shareuserid
     * @return
     * @throws Exception 
     * @author <a href="mailto:android_li@sina.cn">Joe</a>
     */
    @Select("select count(1) from t_behavior_like where promotionid=#{promotionid} and shareuserid=#{shareuserid}")
    int getLike(@Param("promotionid") String promotionid, @Param("shareuserid") String shareuserid);
    
    /**
     * 检查是否已经点赞
     * @param promotionid
     * @param openid
     * @return
     * @throws Exception 
     * @author <a href="mailto:android_li@sina.cn">Joe</a>
     */
    @Select("select count(1) from t_behavior_like where promotionid=#{promotionid} and openid=#{openid}")
    int checkLike(@Param("promotionid") String promotionid, @Param("openid") String openid);
}
